package spring.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@Controller
public class HomeController {
    @RequestMapping(value = "abc/urlMapping")
    public ModelAndView test(HttpServletRequest req, HttpServletResponse response) throws IOException {
        System.out.println("url= " + req.getRequestURL());
        return new ModelAndView("abc/url_mapping");
    }

    @RequestMapping(value = "abc/e")
    public ModelAndView e(HttpServletRequest req, HttpServletResponse response) throws IOException {
        System.out.println("url= " + req.getRequestURL());
        return new ModelAndView("abc/url_mapping");
    }

    @RequestMapping(value = "abc/f")
    public ModelAndView f(HttpServletRequest req, HttpServletResponse response) throws IOException {
        System.out.println("url= " + req.getRequestURL());
        //return new ModelAndView("url_mapping");
        return new ModelAndView("abc/url_mapping");
    }

    @RequestMapping(value = "abc/g")
    public ModelAndView g(HttpServletRequest req, HttpServletResponse response) throws IOException {
        System.out.println("url= " + req.getRequestURL());
        //return new ModelAndView("url_mapping");
        return new ModelAndView("redirect:/a/b");
    }

    @RequestMapping(value = "abc/h")
    public ModelAndView h(HttpServletRequest req, HttpServletResponse response) throws IOException {
        System.out.println("url= " + req.getRequestURL());
        //return new ModelAndView("url_mapping");
        return new ModelAndView("redirect:a/b");
    }
}
